<template>
  <div>
    <titleBox text="公共服务" @click="show = !show"></titleBox>
    <div class="content"
      :style="{ height: show ? height + 'px' : '0px', transition: 'height 0.5s ease-in-out', overflow: 'hidden' }">
      <div class="content-box" ref="content" style="padding: 20px 10px;border: 1px solid #11afc180;">
        <div class="item" v-for="(item, i) in data" :key="i" @click="setGgfwPoint(item.child)">
          <div :style="{ backgroundImage: 'url(' + item.pic + ')' }" class="icon"></div>
          <div class="name">{{ item.name }}</div>
          <div class="num">{{ item.count }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted, nextTick } from "vue"
import $api from "@/utils/request.js"
import titleBox from "../mConponents/titleBox.vue"
const data = ref([])
const emit = defineEmits(["setGgfwPoint"])
const setGgfwPoint = (e) => {
  emit("setGgfwPoint", e)
}
const content = ref(null)
const height = ref(0)
const show = ref(false)
onMounted(() => {
  getData()
})
const getData = async () => {
  const res = await $api.get("api/V1/getGgfw")
  if (res.code === 1) {
    console.log(res)
    data.value = res.data
    nextTick(() => {
      height.value = content.value.offsetHeight
      // show.value = true
    })
  }
}
</script>
<style scoped lang="less">
.content {
  background-color: #001a1dcc;
  border-radius: 5px;
  width: 330px;
  margin-top: 5px;


  .content-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .item {
    width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;

    .icon {
      width: 60px;
      height: 60px;
      background-size: 60px 60px;
    }

    .name {
      color: rgba(193, 244, 255, 1);
      font-family: PingFang SC;
      font-weight: 600;
      font-size: 11px;
      line-height: 19.6px;
      letter-spacing: 0%;

    }

    .num {
      background: linear-gradient(180deg, #00242A 0%, #00434E 100%);
      border: 1px solid rgba(87, 255, 255, 1);
      font-family: PingFang SC;
      font-weight: 400;
      font-size: 9px;
      line-height: 16.8px;
      letter-spacing: 0%;
      color: rgba(255, 255, 255, 1);
      padding: 2px 10px;
      border-radius: 10px;
      margin-top: 5px;

    }
  }
}
</style>
